Many computer systems have a dedicated area of memory known as a "stack", or "pushdown stack", which is particularly useful for quickly storing and retrieving data. Data is generally written to and read from the stack with simple one-word statements. For example, "PUSH A" is a typical command for loading the contents of Register "A" onto the stack. Similarly, "POP A" would result in the data word located at the top of the stack being loaded into Register A. Stack data can generally be accessed faster, e.g., in a single clock cycle, than data stored in other areas of memory. A disadvantage of storing data in a stack, as opposed to other areas of memory, is that data can only be retrieved from the stack on only either a first-in-first-out (FIFO) or a last-in-first-out (LIFO) basis. This is because the contents of the stack registers are pushed down (i.e., each data word is shifted down to the next register in the stack) ever time a new data word is written to the stack, and data located down in the stack can only be accessed either after it is "pushed" out the bottom (FIFO) or after it is or "popped" out the top (LIFO).
Devices for sorting data are known. See for example U.S. Pat. Nos. 3,931,612, 4,651,301, 4,570,221 and 4,559,612. There are times at which it is desirable that data words be sorted and stored in a particular order, such as, for example, on the basis of their magnitudes. In the prior art, data to be stored in a stack is either ranked, or sorted, prior to being loaded into the stack, or it is sorted after all the data words are retrieved from the stack. These sorting operations are costly in terms of the extra memory required for temporarily storing the words to be sorted, and in terms of the time required to perform the sorting operation. This latter cost is particularly undesirable because it defeats one goal of utilizing the stack in the first place i.e., to minimize the time involved in storing and retrieving data.
Thus, it is desirable to provide a device whereby data words are automatically sorted and stored in rank order in a stack-like sequence of registers. Preferrably the data would be automatically maintained in rank order as new words are added to the stack. It is also desirable to provide a device for automatically storing data in rank order in any type of storage device, whether it be a stack, RAM, bubble memory, etc. The present invention achieves these objectives.